package FCRendering.sw;

import java.util.TimerTask;

import FCRendering.FCRMaster;

/**
 * 游戏时间计算线程
 * @author Administrator
 * 
 */
public class FCRDateTimeUpdate extends TimerTask{
	@Override
	public void run() {
		FCRMaster.gamedate.addOneSecond();
		// 非战斗状态下残血时自动恢复血量和体力
		if (!FCRMaster.fcv.isBattle()) {
			autoRecovery();
		}
	}
	/**
	 * 非战斗状态下残血时自动恢复血量，直到恢复到残血线以上（体力恢复同理）
	 */
	private void autoRecovery() {
		// 残血线（最大血量的百分比）
		//			double percentage = 0.3;
		//
		//			boolean bloodLow = player1.getBlood() < (int) (player1.getBloodMax() * percentage);
		//			if (bloodLow) {
		//				player1.addBlood(1);
		//			}
		//			boolean physicalLow = player1.getPhysical() < (int) (player1.getPhysicalMax() * percentage);
		//			if (physicalLow) {
		//				player1.addPhysicalOfNum(1);
		//			}
		//获取玩家1的坐标
		int x=FCRMaster.player1.getPlayer1CoorX(),y=FCRMaster.player1.getPlayer1CoorY();
		//获取玩家所在位置的放置类id
		String name=FCRMaster.mapLib.getMapOfName(FCRMaster.player1.getMapname()).getPlaceNameOfCoor(x,y);
		//在床上才回血
		if(name.equals("Chuang1")) {
			FCRMaster.player1.addBlood(1);
			FCRMaster.player1.addPhysicalOfNum(1);
		}
	}
}
